<template>
	<view class="more">
		<view class="record-lists">
			<view class="record-list" v-for="(item,index) of lists" :key="index">
				<view class="list-time">
					<text class="stage">第 {{item.stage}} 期</text>
					<text class="time">{{formatDateDay(item.create_time*1000)}}</text>
				</view>
				<view class="list-money">
					<text class="currency">数量：<span>{{item.currency}}</span></text>
					<text class="bonus-money">分红：<span>{{item.money}}</span></text>
				</view>
				<view class="status">
					<text class="conduct" v-if="item.status==0">进行中</text>
					<text class="receive" @click="receive()" v-if="item.status==1">领取</text>
					<text class="received" v-if="item.status==2">已领取</text>
				</view>
			</view>
		</view>
		<block-loading :status="status" :len="lists.length"></block-loading>
	</view>
</template>

<script>
	import {getAllConfig,getRules,setBonus,seleAllBonus,receive} from '@/api/entrance.js'
	import {mapActions} from 'vuex';
	import {
		formatDateDay
	} from "@/utils/util.js"
	export default{
		name:"more",
		data(){
			return{
				page:1,
				lists:[],
				status:"loading"
			}
		},
		onLoad() {
			this.getLists();
		},
		onReachBottom(){
			this.getLists();
		},
		methods:{
			...mapActions(['setUserInfo_action']),
			formatDateDay(val){
				return formatDateDay(val)
			},
			async getLists(){
				let res = await seleAllBonus({page:this.page,size:20});
				if(res.code === 1){
					if(this.page===1&&res.data.data.length === 0){
						this.status = "nodata"
						return
					}
					if(this.page===1&&res.data.data.length > 0 && res.data.data.length < 20){
						this.status = "nomore"
					}
					if(res.data.data.length === 0){
						this.status = "nomore"
						return;
					}
					this.page++;
					this.lists = this.lists.concat(res.data.data);
				}
			},
			//领取分红
			async receive(){
				let res = await receive();
				if(res.code === 1){
					this.getLists();
					this.setUserInfo_action();
				}
				this.$msg(res.msg)
			}
		}
	}
</script>

<style lang="less" scoped src="./more.less">
</style>
